package com.kamistoat.meimeimall.common.exception;

// 所有的运行中可抛出异常
public class ALLRunTimeException {

    /**
     * 手机号已存在异常
     */
    public static class PhoneNumUniqueException extends RuntimeException{
        /**
         * Constructs a new runtime exception with {@code null} as its
         * detail message.  The cause is not initialized, and may subsequently be
         * initialized by a call to {@link #initCause}.
         */
        public PhoneNumUniqueException() {
            super("手机号已经存在");
        }
    }

    /**
     * 用户名已存在异常。没有用到，这里只是为了和上面异常凑个对
     */
    public static class UserNameUniqueException extends RuntimeException{
        /**
         * Constructs a new runtime exception with {@code null} as its
         * detail message.  The cause is not initialized, and may subsequently be
         * initialized by a call to {@link #initCause}.
         */
        public UserNameUniqueException() {
            super("用户名已经存在");
        }
    }

    /**
     * 扣库存失败异常
     */
    public static class NoStockException extends RuntimeException{
        /**
         * Constructs a new runtime exception with {@code null} as its
         * detail message.  The cause is not initialized, and may subsequently be
         * initialized by a call to {@link #initCause}.
         */
        private Long skuId;
        public NoStockException(Long skuId) {
            super("商品Id:"+skuId+"没有足够的库存了");
        }

        public Long getSkuId() {
            return skuId;
        }

        public void setSkuId(Long skuId) {
            this.skuId = skuId;
        }
    }

    public static class CommonUseException extends RuntimeException{
        private String msg;
        public CommonUseException(String msg) {super(msg);}
    }
}
